﻿package mortal.game.resource.tableConfig
{
    import Message.DB.Tables.*;
    import __AS3__.vec.*;
    import com.gengine.resource.*;
    import flash.utils.*;
    import mortal.game.view.common.*;

    public class WizardConfig extends Object
    {
        private var _wizardUpArr:Array;
        private var _wizardTargetArr:Array;
        private var _wizardItemDic:Dictionary;
        private var _wizardSkillDic:Dictionary;
        public var vcAttributeName:Vector.<String>;
        private static var _instance:WizardConfig;

        public function WizardConfig()
        {
            this._wizardUpArr = new Array();
            this._wizardTargetArr = new Array();
            this._wizardItemDic = new Dictionary();
            this._wizardSkillDic = new Dictionary();
            this.vcAttributeName = new Vector.<String>;
            if (_instance != null)
            {
                throw new Error(" WizardConfig 单例 ");
            }
            this.init();
            return;
        }// end function

        private function init() : void
        {
            this.vcAttributeName.push("life", "physDefense", "magicDefense", "penetration", "crit", "toughness", "hit", "jouk", "expertise", "block", "attack");
            var _loc_1:* = ConfigManager.instance.getJSONByFileName("t_sprite.json");
            this.write(_loc_1);
            _loc_1 = ConfigManager.instance.getJSONByFileName("t_player_soul_target.json");
            this.writeTarget(_loc_1);
            _loc_1 = ConfigManager.instance.getJSONByFileName("t_player_soul_item.json");
            this.writeItem(_loc_1);
            _loc_1 = ConfigManager.instance.getJSONByFileName("t_sprite_ex.json");
            this.writeSkill(_loc_1);
            return;
        }// end function

        private function write(param1:Object) : void
        {
            var _loc_2:TSprite = null;
            var _loc_3:Object = null;
            for each (_loc_3 in param1)
            {
                
                _loc_2 = new TSprite();
                ClassTypesUtil.copyValue(_loc_2, _loc_3);
                if (this._wizardUpArr[_loc_2.code] == null)
                {
                    this._wizardUpArr[_loc_2.code] = new Array();
                }
                (this._wizardUpArr[_loc_2.code] as Array)[_loc_2.level] = _loc_2;
            }
            return;
        }// end function

        private function writeTarget(param1:Object) : void
        {
            var _loc_2:TPlayerSoulTarget = null;
            var _loc_3:Object = null;
            for each (_loc_3 in param1)
            {
                
                _loc_2 = new TPlayerSoulTarget();
                ClassTypesUtil.copyValue(_loc_2, _loc_3);
                if (this._wizardTargetArr[_loc_2.soulid])
                {
                    this._wizardTargetArr[_loc_2.soulid][_loc_2.level] = _loc_2;
                    continue;
                }
                this._wizardTargetArr[_loc_2.soulid] = new Object();
                this._wizardTargetArr[_loc_2.soulid][_loc_2.level] = _loc_2;
            }
            return;
        }// end function

        private function writeItem(param1:Object) : void
        {
            var _loc_2:TPlayerSoulItem = null;
            var _loc_3:Object = null;
            for each (_loc_3 in param1)
            {
                
                _loc_2 = new TPlayerSoulItem();
                ClassTypesUtil.copyValue(_loc_2, _loc_3);
                this._wizardItemDic[_loc_2.itemcode] = _loc_2;
            }
            return;
        }// end function

        private function writeSkill(param1:Object) : void
        {
            var _loc_2:TSpriteEx = null;
            var _loc_3:Object = null;
            for each (_loc_3 in param1)
            {
                
                _loc_2 = new TSpriteEx();
                ClassTypesUtil.copyValue(_loc_2, _loc_3);
                if (this._wizardSkillDic[_loc_2.code] == null)
                {
                    this._wizardSkillDic[_loc_2.code] = new Dictionary();
                }
                this._wizardSkillDic[_loc_2.code][_loc_2.star] = _loc_2;
            }
            return;
        }// end function

        public function get wizardUpArr() : Array
        {
            return this._wizardUpArr;
        }// end function

        public function get wizardTargetArr() : Array
        {
            return this._wizardTargetArr;
        }// end function

        public function get wizardItemDic() : Dictionary
        {
            return this._wizardItemDic;
        }// end function

        public function getSpriteByCodeAndLevel(param1:int, param2:int) : TSprite
        {
            if (this._wizardUpArr[param1])
            {
                return this._wizardUpArr[param1][param2];
            }
            return null;
        }// end function

        public function get wizardSkillDic() : Dictionary
        {
            return this._wizardSkillDic;
        }// end function

        public function getTSpriteExByCodeAndStar(param1:int, param2:int) : TSpriteEx
        {
            return this._wizardSkillDic[param1][param2] as TSpriteEx;
        }// end function

        public function getSkillTotalStar(param1:int) : int
        {
            var _loc_2:int = 0;
            var _loc_4:TSpriteEx = null;
            var _loc_3:* = this._wizardSkillDic[param1];
            for each (_loc_4 in _loc_3)
            {
                
                _loc_2++;
            }
            return _loc_2;
        }// end function

        public static function get instance() : WizardConfig
        {
            if (_instance == null)
            {
                _instance = new WizardConfig;
            }
            return _instance;
        }// end function

    }
}
